<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    *{
        margin: 0;
        padding: 0;
    }
    body{
        height: 100vh;
				background-size: cover;
				background-image: linear-gradient(#87e9ac,#70def5);
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .content{ 
        display: flex;
        width: 400px;
        height: 300px;
        background-image: linear-gradient(to bottom,#70def5,#87e9ac);
        border-radius: 10px;
        flex-direction: column;
				box-shadow: 0 0 7px gray;
    }
    .logo{
        font-size: 20px;
        text-align: center;
        margin-top: 20px;
    }
    .phone{
        display: flex;
        justify-content: center;
    }
    .phone input{
        padding: 5px;
        margin: 5px;
        width: 100%;
        margin-top: 40px;
				background: none;
				border: none;
				border-bottom: 1px solid white ;
    }
    .input_YZM{
        padding: 5px;
        margin: 5px;
        width: 70%;
				background: none;
				border: none;
				border-bottom: 1px solid white ;
				margin-top: 10px;
    }
    #accoss_token{
        padding: 3.5px;
        cursor: pointer;
        background-color: cornflowerblue;
        border: none;
        border-radius: 2px;
    }
    #submit{
        padding: 10px;
        margin-top: 50px;
        width: 100%;
        background-color: cornflowerblue;
        border: none;
        cursor: pointer;
        border-radius: 5px;
				color: white;
    }
		.phone input::placeholder{
			color: white;
		}
		.input_YZM::placeholder{
			color: white;
		}
		a{
			text-align: center;
		}
</style>
<body>
    <div class="content">
        <div class="logo">
            忘记密码
        </div>
        <div class="phone">
            <input type="text" name="" id="phone" placeholder="电话">
        </div>
        <div class="YZM">
            <input type="text" name="" id="input_YZM" placeholder="验证码" class="input_YZM">
            <input type="button" value="获取验证码" id="accoss_token">
        </div>
        <div class="submit">
            <input type="button" value="提交" id="submit">
        </div>
				<a href="./login.html">返回登录界面</a>
    </div>

    <script src="js/jquery.min.js"></script>
    <script>
        $("#accoss_token").click(function(){
            // alert($("#phone").val());
            $("#accoss_token").attr("disabled", true).val("60s后获取");
           
            $.ajax({
                url :"http://123.56.67.48:8080/sendMsg",
                data: {
                    phone : $("#phone").val()
                },
                success:function(res){
                    console.log(res);
                },
                error:function(){
                    console.log("失败");
                }
            })

            setTimeout(function(){
            $("#accoss_token").removeAttr("disabled").val('重新获取').css("cursor","pointer");
           },60000);
        })


        $("#submit").click(function(){
						var phone = $("#phone").val();
						//alert(phone)
						
            $.ajax({
                url :"http://123.56.67.48:8080/ver",
								method:"GET",
								// xhrFields:{
								// 	withCredentials:true,
								// },
								contentType:'application/json',
                data: {
                    yzm : $("#input_YZM").val(),
										phone : $("#phone").val()
                },
                success:function(res){
									console.log(res);
                    if(JSON.parse(res).code == 1){
											window.location.href = "./ChangePWD.html?phone="+phone;
										}
                },
                error:function(){
                    console.log("失败");
                }
            })
        })

    </script>
</body>
</html>